package com.aspose.cells;

class zbub extends zq {
   private int c;
   private int d;
   private zbub.za e;

   zbub(int var1, Cells var2, RowCollection var3) {
      super(var2, var3);
      this.c = var1;
      this.d = -1;
   }

   public int b() {
      return this.d;
   }

   public void b(int var1) {
      this.d = var1;
   }

   public void a() {
      while(this.e != null) {
         this.e.b.b.a();
         this.e = this.e.a;
      }

   }

   public Row a(int var1) {
      if (this.e == null) {
         return null;
      } else if (this.e.b.getIndex() == var1) {
         return this.e.b;
      } else {
         zbub.za var2 = this.e;

         for(zbub.za var3 = this.e.a; var3 != null; var3 = var3.a) {
            if (var3.b.getIndex() == var1) {
               var2.a = var3.a;
               var3.a = this.e;
               this.e = var3;
               return this.e.b;
            }

            var2 = var3;
         }

         return null;
      }
   }

   public Row a(int var1, boolean var2) {
      this.d = var1;
      if (this.e == null) {
         this.e = new zbub.za();
         this.e.b = new Row(this.a, this.b, this.b.c.f(var1), var2);
         return this.e.b;
      } else {
         int var3 = this.b.c.a(var1);
         if (this.e.b.getIndex() == var3) {
            this.e.b.a.f(var1);
            return this.e.b;
         } else {
            zbub.za var4 = this.e;
            zbub.za var5 = this.e.a;

            for(int var6 = 2; var5 != null; ++var6) {
               if (var5.b.getIndex() == var3) {
                  var5.b.a.f(var1);
                  var4.a = var5.a;
                  var5.a = this.e;
                  this.e = var5;
                  return this.e.b;
               }

               if (var6 >= this.c) {
                  var4.a = null;
                  var5.b = new Row(this.a, this.b, this.b.c.f(var1), true);
                  var5.a = this.e;
                  this.e = var5;
                  return this.e.b;
               }

               var4 = var5;
               var5 = var5.a;
            }

            var5 = new zbub.za();
            var5.b = new Row(this.a, this.b, this.b.c.f(var1), true);
            var5.a = this.e;
            this.e = var5;
            return this.e.b;
         }
      }
   }

   public Row a(int var1, boolean var2, boolean var3, boolean var4) {
      if (this.e == null) {
         Row var9 = this.b(var1, var2, var3, var4);
         if (var9 == null) {
            return null;
         } else {
            this.e = new zbub.za();
            this.e.b = var9;
            return var9;
         }
      } else if (this.e.b.a.h() == var1) {
         if (this.a(this.e.b, var2, var3)) {
            return this.e.b;
         } else {
            this.e = this.e.a;
            return null;
         }
      } else {
         zbub.za var5 = this.e;
         zbub.za var6 = this.e.a;

         Row var8;
         for(int var7 = 2; var6 != null; ++var7) {
            if (var6.b.a.h() == var1) {
               if (this.a(var6.b, var2, var3)) {
                  var5.a = var6.a;
                  var6.a = this.e;
                  this.e = var6;
                  return this.e.b;
               }

               var5.a = var6.a;
               return null;
            }

            if (var7 >= this.c) {
               var8 = this.b(var1, var2, var3, var4);
               if (var8 == null) {
                  return null;
               }

               var5.a = null;
               var6.b = var8;
               var6.a = this.e;
               this.e = var6;
               return var8;
            }

            var5 = var6;
            var6 = var6.a;
         }

         var8 = this.b(var1, var2, var3, var4);
         if (var8 == null) {
            return null;
         } else {
            var6 = new zbub.za();
            var6.a = this.e;
            var6.b = var8;
            this.e = var6;
            return var8;
         }
      }
   }

   private class za {
      zbub.za a;
      Row b;

      private za() {
      }

      // $FF: synthetic method
      za(Object var2) {
         this();
      }
   }
}
